﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Core
{
    [DisallowMultipleComponent]
    public class BaseReferenceItem : GameMono
    {
        [Header("是否自适应为父节点的大小（仅UI）")]
        public bool isAdjustByParent;

        internal void _OnInit()
        {
            OnInit();
        }

        /// <summary>
        /// 初始化
        /// </summary>
        protected virtual void OnInit() { }

        public void AdjustByParent()
        {
            RectTransform rect = transform as RectTransform;
            if (rect == null)
                return;

            rect.anchorMin = Vector2.zero;
            rect.anchorMax = Vector3.one;
            rect.offsetMin = Vector2.zero;
            rect.offsetMax = Vector2.zero;
            rect.sizeDelta = Vector2.zero;
        }
    }
}
